import Vue from '@/main.js';
export function getAgencyList() {

}
export function insertAgency() {

}

//下载附件
export function Dowfile(id, name) {
  var path = `/business/residentialQuarters/downloadAnnex?id=${id}&filename=${name}`;
  return Vue.$http.get(path)
    .then((res) => {
      return res;
    })
    .catch(function (error) {
      console.log(error);
    });
}

//删除楼宇
export function DelBuilding(id) {
  var path = `/business/building/delete?id=${id}`;
  return Vue.$http.get(path)
    .then((res) => {
      return res;
    })
    .catch(function (error) {
      console.log(error);
    });
}

//下拉机关列表
export function getJiGuanList(type,name) {
  var path = `/business/agency/getAgencySelectData?type=${type}&name=${name}`;
  return Vue.$http.get(path)
    .then((res) => {
      return res.data.data;
    })
    .catch(function (error) {
      console.log(error);
    });
}
//下拉机构列表
export function getJiGouList(type, name) {
  var path = `/business/company/getCompanySelectData?type=${type}&name=${name}`;
  return Vue.$http.get(path)
    .then((res) => {
      return res.data.data;
    })
    .catch(function (error) {
      console.log(error);
    });
}
//机构部门列表
export function getJiGouBuMenList(params) {
  var path = `/auth/department/getDepartmentListByUnit`;
  return Vue.$http.post(path, params)
    .then((res) => {
      return res.data.data;
    })
    .catch(function (error) {
      console.log(error);
    });
}
//获取上级机构列表
export function getShangJiJiGouList(code) {
  var path = `/business/company/getFatherCompanies?shortName=`;
  return Vue.$http.get(path)
    .then((res) => {
      return res.data.data;
    })
    .catch(function (error) {
      console.log(error);
    });
}
//子级地区信息
export function getcityList(code) {
  var path = `/business/dictionary/queryAreaList?fatherCode=${code}`;
  return Vue.$http.get(path)
    .then((res) => {
      return res.data.data;
    })
    .catch(function (error) {
      console.log(error);
    });
}

export function getreList(params) {
  var path = "/business/residentialQuarters/list";
  return Vue.$http.post(path, params)
    .then((res) => {
      return res.data.data;
    })
    .catch(function (error) {
      console.log(error);
    });
}



export function getFatherAgencies(name) {
  var path = "/business/agency/getFatherAgencies?name=" + name;
  return Vue.$http.get(path)
    .then((res) => {
      return res.data;
    })
    .catch(function (error) {
      console.error(error);
    });
}

// 新增小区
export function addXiaoQu(reinsertForm) {
  var path = "/business/residentialQuarters/insert";
  return Vue.$http.post(path, reinsertForm)
    .then((res) => {
      return res.data;
    })
    .catch(function (error) {
      console.log(error);
    });
}




export function deleteinstInformation(id) {
  var path = "/business/residentialQuarters/delete?id=" + id;
  return Vue.$http.get(path)
    .then((res) => {
      return res.data;
    })
    .catch(function (error) {
      console.log(error);
    });
}



export function getInDetail(id) {
  var path = "/business/residentialQuarters/detail?id=" + id;
  return Vue.$http.get(path)
    .then((res) => {
      return res.data.data;
    })
    .catch(function (error) {
      console.error(error);
    });
}


export function updateinstInfo(reinsertForm) {
  var path = "/business/residentialQuarters/update";
  return Vue.$http.post(path, reinsertForm)
    .then((res) => {
      return res.data;
    })
    .catch(function (error) {
      console.log(error);
    });
}


export function getDictionaryList(category) {
  var path = "/business/dictionary/queryList?category=" + category;
  return Vue.$http.get(path)
    .then((res) => {
      return res.data;
    })
    .catch(function (error) {
      console.error(error);
    });
}



export function bindingAU(agencyId, userId) {
  var path = "/business/company/bindingCU?companyId=" + agencyId + "&userId=" + userId;
  return Vue.$http.get(path)
    .then((res) => {
      return res.data;
    })
    .catch(function (error) {
      console.error(error);
    });
}

export function unbindingAU(agencyId, userId) {
  var path = "/business/company/unbindingCU?companyId=" + agencyId + "&userId=" + userId;
  return Vue.$http.get(path)
    .then((res) => {
      return res.data;
    })
    .catch(function (error) {
      console.error(error);
    });
}






export function getPostListByDepId(depId) {
  var path = "/business/companyPost/getPostListByDepId";
  return Vue.$http.post(path, {
    depId: depId,
  }).then((res) => {
    return res.data;
  })
    .catch(function (error) {
      console.log(error);
    });
}



export function addStaff(companyId, userIds, depIds, postIds) {
  var path = "/business/companyStaff/addStaff";
  return Vue.$http.post(path, {
    companyId: companyId,
    userIds: userIds,
    depIds: depIds,
    postIds: postIds,
  }).then((res) => {
    return res.data;
  })
    .catch(function (error) {
      console.log(error);
    });
}


//楼宇列表
export function getAddedUserList(params) {
  var path = "/business/building/list";
  return Vue.$http.post(path, params).then((res) => {
    return res.data.data;
  })
    .catch(function (error) {
      console.log(error);
    });
}

export function deleteStaff(staffId) {
  var path = "/business/companyStaff/delete?id=" + staffId;
  return Vue.$http.get(path)
    .then((res) => {
      return res.data;
    })
    .catch(function (error) {
      console.error(error);
    });
}

export function getBreadcrumbs(agencyId) {
  var path = "/business/company/getFatherCompanyData?companyId=" + agencyId;
  return Vue.$http.get(path)
    .then((res) => {
      return res.data.data;
    })
    .catch(function (error) {
      console.error(error);
    });
}

export function getAgencyStaffDetail(id) {
  var path = "/business/agencyStaff/detail?id=" + id;
  return Vue.$http.get(path)
    .then((res) => {
      return res.data;
    })
    .catch(function (error) {
      console.error(error);
    });
}



export function updateStaff(id, agencyId, userId, depIds, postIds) {
  var path = "/business/agencyStaff/updateStaff";
  return Vue.$http.post(path, {
    id: id,
    agencyId: agencyId,
    userId: userId,
    depIds: depIds,
    postIds: postIds,
  }).then((res) => {
    return res.data;
  })
    .catch(function (error) {
      console.log(error);
    });
}

